
 #include<stdio.h>
 #include<stdlib.h>
void main (void)
{
int i, n;
char * buffer; // point to the variable buffer location.The type of this pointer is always void*, which can be cast to the desired type of data pointe

printf ("How long do you want the string? ");
scanf("%d", &i); // string size

buffer = (char*) malloc (i+1);
//Allocates a block of size bytes of memory, returning a pointer to the beginning of the block. The possible length of this string is only limited by the amount of memory available to malloc 

if (buffer == NULL)// If the function failed to allocate the requested block of memory, a null pointer is returned.
exit (1);

for (n=0; n<i; n++) {
buffer[n] = rand() % 26 +'a';
}
buffer[i]='\0';

printf ("Random string: %s\n",buffer);

free (buffer); //Deallocate memory block 

}
/* This program generates a string of the length specified by the user and fills it with alphabetic characters. The possible length of this string is only limited by the amount of memory available to malloc

Data races
Only the storage referenced by the returned pointer is modified. No other storage locations are accessed by the call.
If the function reuses the same unit of storage released by a deallocation function (such as free or realloc), the functions are synchronized in such a way that the deallocation happens entirely before the next allocation.
*/
